<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
        <title>我的提现管理</title>
        {''|getCommon} 
		{'easyui'|getPlugSingle}
		{'ztree'|getPlugSingle}
	</head>
    <body>
        <table id="dataListTb" title="我的提现管理" style="width:100%;" data-options="collapsible:true,rownumbers:true,singleSelect:true,pagination:true,url:'queryDrawInfo',method:'post',toolbar:'#withDrawTool',multiSort:false">
			<thead>
				<tr>
					<th data-options="field:'withdMo',resizable:false" width="7%">提现金额(元)</th>
					<th data-options="field:'withdCounterMo',resizable:false" width="8%">收取手续费(元)</th>
					<th data-options="field:'withdTotalMo',align:'left',resizable:false" width="7%">总计金额(元)</th>
					<th data-options="field:'withdCreatetime',align:'left',formatter:nullFix,resizable:false" width="12%">提现时间</th>
					<th data-options="field:'withdPassTime',resizable:false,formatter:nullFix" width="12%">审核通过时间</th>
					<th data-options="field:'withdState',formatter:formatState,resizable:false" width="6%">提现状态</th>
					<th data-options="field:'withBankNo',formatter:getBankInfo,resizable:false" width="40%">提现银行卡</th>
					<th data-options="field:'userLoginId',formatter:nullFix" width="7%">审核人</th>
				</tr>
			</thead>
		</table>
		<div id="withDrawTool" style="padding:5px;height:auto">
			<div style="margin-bottom:5px">
				<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addRole();">提现</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-reload" plain="true" onclick="javascript:window.location.reload()">刷新</a>
			</div>
			<div>
				<form id="queryTableInfo" method="post">
					提现时间: <input class="easyui-datebox" name="withdCreatetimeStart" style="width:120px">
					到: <input class="easyui-datebox" name="withdCreatetimeEnd" style="width:120px">
					审核状态: 
					<select class="easyui-combobox" name="withdState" panelHeight="auto" style="width:100px">
						<option value="4">所有状态</option>
						<option value="1">待审核中</option>
						<option value="2">审核通过</option>
						<option value="3">审核失败</option>
					</select>
					<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="queryTableInfo()">搜索</a>
					<a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="clearTbForm()">清空条件</a>
				</form>
			</div>
		</div>
		<div id="addWithDraw" class="easyui-dialog" title="提现" closed="true" style="width:320px;height:320px;padding:10px"
    	data-options="
				iconCls: 'icon-add',
				buttons: [{
					text:'提现',
					iconCls:'icon-ok',
					handler:function(){
						$('#addWithDrawForm').form('submit', {
							url : 'insertWithDraw',
							onSubmit : function() {
								return $(this).form('validate');
							},
							success : function(data) {
								eval('var dataJson='+data);
								if(dataJson.result==true){
									$.messager.show({
										title : '提示',
										msg :'提现成功耐心等待审核'
									});
									$('#addWithDraw').dialog('close');
									$('#dataListTb').datagrid();
								}else{
									$.messager.show({
										title : '提示',
										msg :dataJson.result
									});
								}
							}
						}); 
					}
				},{
					text:'关闭',
					handler:function(){
						$('#addWithDraw').dialog('close');
					}
				}],
				onResize:function(){
					$(this).dialog('center');
				}
			">
			<form id="addWithDrawForm" method="post"><br/>
		    	<table cellpadding="5">
		    		<tr>
		    			<td>剩余野猪币:</td>
		    			<td><span id="balance" style="color:red">0</span>(野猪币低于<span style="color:red">1000</span>不可提现)
		    				<input type="hidden" id="userBalance">
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>&nbsp;</td>
		    			<td>&nbsp;</td>
		    		</tr>
		    		<tr>
		    			<td>注意:</td>
		    			<td>每笔提现需扣除<span style="color:red">5%</span>手续费</td>
		    		</tr>
		    		<tr>
		    			<td>&nbsp;</td>
		    			<td>&nbsp;</td>
		    		</tr>
		    		<tr>
		    			<td>所属银行:</td>
		    			<td><input class="easyui-textbox" name="withBankName" id="withBankName" required="true" missingMessage="必须填写所属银行"></input></td>
		    		</tr>
		    		<tr>
		    			<td>开户支行地址:</td>
		    			<td><input class="easyui-textbox" min="0.0" name="withBankAccount" id="withBankAccount" maxlength="30"></input></td>
		    		</tr>
		    		<tr>
		    			<td>银行卡卡号:</td>
		    			<td><input class="easyui-numberbox" min="0" name="withBankNo" id="withBankNo"  required="true" missingMessage="必须填写银行卡卡号"></input></td>
		    		</tr>
		    		<tr>
		    			<td>持卡人姓名:</td>
		    			<td><input class="easyui-textbox" min="0.0" name="withBankUserName" id="withBankUserName"  required="true" missingMessage="必须填写持卡人姓名"></input></td>
		    		</tr>
		    		<tr>
		    			<td>提现金额:</td>
		    			<td><input class="easyui-numberbox" min="0.0" name="withdMo" id="withdMo"  precision="2" required="true" missingMessage="必须填写有效金额,并且至少100元" validType="withDrawMin[100]"></input></td>
		    		</tr>
		    		<tr>
		    	</table>
		    </form>
		</div>
		<script type="text/javascript">
			$.extend($.fn.validatebox.defaults.rules, {
				withDrawMin: {
					validator: function(value, param){
						if(!value){
							return false;
						}
						return value >= param[0];
					},
					message: '提现金额最少100元'
				}
			});
			//状态解释器
			function formatState(val,row){
				switch(val){
					case '1':
						return '<span style="color:blue;">待审核中</span>';
						break;
					case '2':
						return '<span style="color:green;">审核通过</span>';
						break;
					case '3':
						return '<span style="color:red;">审核失败</span>';
						break;	
					default:
						return '<span style="color:#333333;">-</span>';
						break;
				}
			}
			//添加新用户
			function addRole(){
				//每次打开前都要清除先前填写的信息
				$('#addWithDrawForm').form('clear');
				$.ajax({  
					type : "post",  
					url : "getBalance",    
					async : false,  
					success : function(data){
						eval('var dataJson = '+data);
						var result = dataJson.balance;
						$('#balance').text(result);
						$('#userBalance').val(result);
						$('#addWithDraw').dialog('open');
				    }
				});
			}
			function getBankInfo(val,row){
				if(val==''){
					return '-';
				}
				return row.withBankUserName+"("+row.withBankName+":"+row.withBankNo+")开户行地址:"+row.withBankAccount;
			}
			//带条件查询信息
			function queryTableInfo(){
				$("#dataListTb").datagrid("load", {
					withdCreatetimeStart:$('#queryTableInfo input[name="withdCreatetimeStart"]').val(),
					withdCreatetimeEnd:$('#queryTableInfo input[name="withdCreatetimeEnd"]').val(),
					withdState:$('#queryTableInfo input[name="withdState"]').val()
		        });
			}
			
			//清空条件
			function clearTbForm(){
				$('#queryTableInfo').form('clear');
			}
			
			{literal}
			//如果为空就显示-
			function nullFix(val,row){
				if(val==null || val=='')return '-';
				else return val;
			}
			{/literal}
		
			$(function(){
				var pager = $('#dataListTb').datagrid({
					method: 'POST',
					loadMsg: '数据加载中,请稍候...',
					pagination: true,   
					pageSize: 15,//每页显示的记录条数，默认为10 
					pageList: [15, 30, 45]//可以设置每页记录条数的列表  
				}).datagrid('getPager');	// get the pager of datagrid
				pager.pagination(
					{ pageSize: 15,//每页显示的记录条数，默认为20
			        pageList: [15,30,45] }//可以设置每页记录条数的列表 
				);			
			})
		</script>
    </body>
</html>
